package cn.yudao.ymcc.searchDoc;

import com.baomidou.mybatisplus.annotations.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import javax.validation.constraints.NotEmpty;
import java.math.BigDecimal;
import java.util.Date;

@Document(indexName = "course", type = "_doc") // 创建索引doc， 类型名为_doc
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CourseDoc {

    @Id // 配置文档的每行的id
    private Long id;

    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_max_word")
    private String name; // 课程名称

    @Field(type = FieldType.Keyword)
    private String gradeName; // 等级名称

    @Field(type = FieldType.Keyword)
    private String forUser; //适用人群

    @Field(type = FieldType.Long)
    private Long courseTypeId; // 课程分类

    @Field(type = FieldType.Keyword)
    private String courseTypeName; // 课程分类

    @Field(type = FieldType.Long)
    private Long gradeId; // 课程等级id

    @Field(type = FieldType.Date)
    private Date startTime; // 开课时间

    @Field(type = FieldType.Date)
    private Date endTime; // 节课时间

    @Field(type = FieldType.Keyword)
    private String pic; // 封面

    @Field(type = FieldType.Integer)
    private Integer totalMinute; // 时长，以分钟为单位

    @Field(type = FieldType.Date)
    private Date onlineTime; // 课程上架时间

    @Field(type = FieldType.Integer)
    private Integer chapterCount; // 章节数

    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_max_word")
    private String teacherNames;

    @Field(type = FieldType.Integer)
    private Integer charge; // 收费规则

    @Field(type = FieldType.Keyword)
    private String chargeName; // 收费规则

    @Field(type = FieldType.Double)
    private BigDecimal price; // 售价

    @Field(type = FieldType.Double)
    private BigDecimal priceOld; // 原价

    @Field(type = FieldType.Integer)
    private Integer validDays; // 课程天数

    @Field(type = FieldType.Integer)
    private Integer saleCount; //销量

    @Field(type = FieldType.Integer)
    private Integer viewCount; // 浏览量

    @Field(type = FieldType.Integer)
    private Integer commentCount; //评论数

}
